﻿@{
	Layout = null;
}
<!DOCTYPE html>
<html lang="zh-CN">
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<title>职称设置</title>
	<link rel="stylesheet" href="https://unpkg.com/element-plus/dist/index.css">
</head>
<body>
	<script src="https://unpkg.com/vue@3"></script>
	<!-- 引入Element Plus -->
	<script src="https://unpkg.com/element-plus"></script>
	<!-- 引入axios -->
	<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
	<div id="app">
		<el-form :model="formData" ref="formData" label-width="110px" class="demo-ruleForm">
			<table width="100%">
				<tr>
					<td>
						<font color="black">您正在做的业务是：人力资源--权限管理--添加用户</font>
					</td>
				</tr>
				<tr>
					<td align="right">
						<el-button style="float:right" v-on:click="Add()">保存</el-button>
						<el-button style="float:right" onclick="history.back()">返回</el-button>
					</td>
				</tr>
			</table>
			<table width="100%" border="1" cellpadding=3 cellspacing=1 class="TABLE_STYLE1">
				<tr>
					<td class="TD_STYLE1">用户名称</td>
					<td class="TD_STYLE2">
						<el-form-item prop="userName">
							<el-input v-model="formData.uName"></el-input>
						</el-form-item>
					</td>
					<td class="TD_STYLE1">用户密码</td>
					<td class="TD_STYLE2">
						<el-form-item prop="UPassWord">
							<el-input v-model="formData.uPassWord"></el-input>
						</el-form-item>
					</td>
				</tr>
				<tr>
					<td class="TD_STYLE1">真实姓名</td>
					<td class="TD_STYLE2">
						<el-form-item prop="UTrueName">
							<el-input v-model="formData.uTrueName"></el-input>
						</el-form-item>
					</td>
					<td class="TD_STYLE1">用户身份</td>
					<td class="TD_STYLE2">
						<el-form-item prop="Uidentity">
							<el-select v-model="selected" placeholder="请选择">
								<el-option v-for="item in options"
										   :value="item.attributeName"
										   :label="item.attributeName"
										   :key="item.pbcId" />
							</el-select>
						</el-form-item>
					</td>
				</tr>
			</table>
		</el-form>
	</div>

	<script>
		const app = Vue.createApp({
			data() {
				return {
					formData: {
						uId: 0,
						uName: '',
						uPassWord: '',
						uTrueName: '',
						uidentity: '',
					},
					selected: "",
					options: [],
					attributeName: '',
					pbcId: 0,
				};
			},
			methods: {
				xllb() {
					const vm = this;
					axios.get("/User/GetName")
						.then(function (response) {
							vm.options = response.data;
						})
						.catch(function (error) {
							console.error(error);
							alert("请求失败");
						});
				},
				Add() {
					const vm = this;
					axios.get("/User/UserAdd?UName=" + this.formData.uName + "&UTrueName=" + this.formData.uTrueName + "&UPassWord=" + this.formData.uPassWord + "&Uidentity=" + this.selected + "&UId=" + this.uid)
						.then(function (response) {
							if (response.data) {
								alert("添加成功");
								window.location.href = "/User/yh";//页面跳转
							} else {
								alert("添加失败");
							}
						})
						.catch(function (error) {
							console.error(error);
							alert("请求失败");
						});
				}
			},
			mounted() {
				this.xllb();
			}
		});

		// 安装 Element Plus
		app.use(ElementPlus);

		// 挂载应用程序到页面上
		app.mount("#app");
	</script>
</body>
</html>
